package com.woniu.utils;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author Rain
 * @Description : 统计Controller访问时间
 * @date 2022/08/26 16:00
 */
public class TimeFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        filterChain.doFilter(servletRequest,servletResponse);
        long end = System.currentTimeMillis();
        System.err.println("后台时间" + (end - start));
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
